<%@ page pageEncoding="ISO-8859-1" contentType="text/html; charset=ISO-8859-1" %>
<%@ page isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<fmt:setBundle basename="MessageResources"/>

<c:if test="${empty elementList}">
	<p align="center"><fmt:message key="element.query.empty"/></p>
</c:if>
<c:if test="${not empty elementList}">
	<form name="elementCheckForm" method="post" action="${param['formAction']}?fwd=${param['fwd']}">
		<input name="deleteSelected" type="submit" value="<fmt:message key='element.delete.form.submit.label'/>">
		<br><br>
		<table border width="100%" cellpadding="1" bgcolor="#ffffff">
			<tr>
				<th width="16">
					<c:set var="checkAllJs" value="var isChecked = document.elementCheckForm.checkAll.checked;"/>
					<c:forEach items="${elementList}" var="eachElement">
						<c:set var="checkAllJs" value="${checkAllJs} document.elementCheckForm.e${eachElement.id}checkbox.checked = isChecked;"/>
					</c:forEach>
					<input name="checkAll" type="checkbox" onclick="${checkAllJs}">
				</th>
				<th><b><fmt:message key="treatment.description"/></b></th>
				<th><b><fmt:message key="treatment.disease"/></b></th>
				<th><b><fmt:message key="treatment.behaviors"/></b></th>
				<th><b><fmt:message key="treatment.drugs"/></b></th>
				<th><b><fmt:message key="treatment.foods"/></b></th>
				<th width="16"></th>
			</tr>
			<c:forEach items="${elementList}" var="eachElement">
				<tr>
					<td align="center"><input name="e${eachElement.id}checkbox" type="checkbox"></td>
					<td>${eachElement.description}</td>
					<td>${eachElement.disease.name}: ${eachElement.disease.description}</td>
					<td>
						<c:if test="${empty eachElement.behaviors}">
							<fmt:message key="treatment.query.behaviorsList.empty"/>
						</c:if>
						<c:if test="${not empty eachElement.behaviors}">
							<table border cellpadding=1>
								<tr>
									<th><b><fmt:message key="behavior.name"/></b></th>
									<!-- <th><b><fmt:message key="behavior.description"/></b></th> -->
								</tr>
								<c:forEach items="${eachElement.behaviors}" var="eachBehavior">
									<tr>
										<td>${eachBehavior.name}</td>
										<!-- <td>${eachBehavior.description}</td> -->
									</tr>
								</c:forEach>
							</table>
						</c:if>
					</td>
					<td>
						<c:if test="${empty eachElement.drugs}">
							<fmt:message key="treatment.query.drugsList.empty"/>
						</c:if>
						<c:if test="${not empty eachElement.drugs}">
							<table border cellpadding=1>
								<tr>
									<th><b><fmt:message key="drug.scientificName"/></b></th>
									<th><b><fmt:message key="drug.commercialName"/></b></th>
								</tr>
								<c:forEach items="${eachElement.drugs}" var="eachDrug">
									<tr>
										<td>${eachDrug.scientificName}</td>
										<td>${eachDrug.commercialName}</td>
									</tr>
								</c:forEach>
							</table>
						</c:if>
					</td>
					<td>
						<c:if test="${empty eachElement.foods}">
							<fmt:message key="treatment.query.foodsList.empty"/>
						</c:if>
						<c:if test="${not empty eachElement.foods}">
							<table border cellpadding=1>
								<tr>
									<th><b><fmt:message key="food.name"/></b></th>
								</tr>
								<c:forEach items="${eachElement.foods}" var="eachFood">
									<tr>
										<td>${eachFood.name}</td>
									</tr>
								</c:forEach>
							</table>
						</c:if>
					</td>
					<td align="center">
						<a href="deleteTreatment.do?eID=${eachElement.id}&fwd=${param['fwd']}">
							<img src="images/icons/delete.png" border="0" width="16" height="16" title="<fmt:message key='element.query.deleteCol.label'/>" alt="<fmt:message key='element.query.deleteCol.label'/>">
						</a>
						<br>
						<a href="updateTreatment.do?eID=${eachElement.id}&fwd=${param['fwd']}">
							<img src="images/icons/edit.png" border="0" width="16" height="16" title="<fmt:message key='element.query.editCol.label'/>" alt="<fmt:message key='element.query.editCol.label'/>">
						</a>
					</td>
				</tr>
			</c:forEach>
		</table>
	</form>
</c:if>
